package com.huiztech.maystall.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.Toast;

public class MoreOptionsActivity extends Activity {

    private RelativeLayout findFriendLayout, opinionLayout, clearCacheLayout, tuisongLayou,examineUpdateLayout;
    private AlertDialog dialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_more);

        examineUpdateLayout = (RelativeLayout) findViewById(R.id.more_examine_update_layout);
        examineUpdateLayout.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View v) {
                Toast.makeText(MoreOptionsActivity.this, "已经是最新版本！", Toast.LENGTH_SHORT).show();
            }
        });
        
        findFriendLayout = (RelativeLayout) findViewById(R.id.more_find_friend_layout);
        findFriendLayout.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MoreOptionsActivity.this, FindFriendActivity.class);
                startActivity(intent);
            }
        });

        opinionLayout = (RelativeLayout) findViewById(R.id.more_opinion_layout);
        opinionLayout.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MoreOptionsActivity.this, OpinionActivity.class);
                startActivity(intent);
            }
        });

        clearCacheLayout = (RelativeLayout) findViewById(R.id.more_clear_cache_layout);
        clearCacheLayout.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                clearCache();
            }
        });

        tuisongLayou = (RelativeLayout) findViewById(R.id.more_tuisong_layout);
        tuisongLayou.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                tuisongSet();
            }
        });
    }

    private void clearCache() {
        dialog = new AlertDialog.Builder(MoreOptionsActivity.this).create();
        dialog.show();
        dialog.getWindow().setContentView(R.layout.clear_cache_dialog);
        dialog.getWindow().findViewById(R.id.clear_cache_cancel_btn).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        dialog.getWindow().findViewById(R.id.clear_cache_submit_btn).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

    }

    private void tuisongSet() {
        dialog = new AlertDialog.Builder(MoreOptionsActivity.this).create();
        dialog.show();
        dialog.getWindow().setContentView(R.layout.tuisong_dialog);
        dialog.getWindow().findViewById(R.id.tuisong_cancel_btn).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        dialog.getWindow().findViewById(R.id.tuisong_submit_btn).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
    }

}
